<%@page import="com.ycxy.syt.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.ycxy.syt.DBDao"%>
<%@page import="java.sql.*"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE>
<html>

<head>
<title>登录验证</title>
<meta http-equiv="refresh" content="3;url=shopp.jsp"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
</head>

<body>
  <%
  	HttpSession session2 = request.getSession();
  	
 	String username = request.getParameter("username");
 	String password = request.getParameter("password");
 	
 	String sql = " select username from user where username = '"+username+"' and password = '"+password+"';";
 	DBDao dao = new DBDao();
 	ResultSet res1 = (dao.queryBySQL(sql));
 	
 	String res = "0";
 	while(res1.next()){
 		res = res1.getString(1);
 	}
 	
 	if( res == "0" ){
 		out.print("用户名或者账号错误,登录失败<br>");
 		out.print("3秒后跳转*****到登录界面<br>");
 		out.print("未跳转,请<a href='login.html'>点击</a>");
 	}
 	else{
 		User user = new User();
 		user.setUsername(username);
 		user.setPassword(password);
 		//request.getSession().setAttribute("user", user);
 		//response.sendRedirect("LoginServlet.jsp");
 		out.print("登录成功<br>");
 		out.print("3秒后跳转*****到首页<br>");
 		out.print("未跳转,请<a href='shopp.jsp'>点击</a>");
 		session2.getAttribute("user");
 	}
   %>
   
  </body>

</html>
